package com.gxa.controller;

import com.gxa.common.JsonResult;
import com.gxa.common.PageRecv;
import com.gxa.common.R;
import com.gxa.pojo.RepairOrder;
import com.gxa.service.RepairOrderService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

//富文本砍掉
@Controller
@RequestMapping(value = "/repairOrder")
@Api(value = "工单数据test",tags = "工单数据接口API-周军国")
public class RepairOrderController {
    @Autowired
    private RepairOrderService repairOrderService;
    //工单数据添加的工作描述能添加图片；添加工单时能同时添加多个附件
    //获取发起人或者指派人员是自己的工单
    @RequestMapping(value = "/addrepairOrder",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "工单添加接口",notes = "向数据库添加无关联客户工单和有关联客户工单信息",httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R addRepairOrder(@RequestBody @ApiParam(name = "repairOrder",value = "存储添加工单页面的数据信息",required = true) RepairOrder repairOrder){
        R r= new R();
//        System.out.println(repairOrder);
        r=repairOrderService.addRepairOrder(repairOrder);
        return r;
    }
    @RequestMapping(value = "/queryRepairOrder",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "工单查询接口",notes = "支持工单列表、我发起的、我参与的、所有工单、已完成、处理中、未处理",httpMethod = "post", response = JsonResult.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
//   实体套员工实体、工单类型实体、客户联系人实体、交通方式实体
public JsonResult queryRepairOrder(@RequestBody @ApiParam(name = "pageRecv",value = "存储查询工单页面的数据信息",required = true) PageRecv<RepairOrder> pageRecv){
        JsonResult r=new JsonResult();
        r=repairOrderService.queryRepairOrder(pageRecv);
        System.out.println(pageRecv.getData().toString());
        return r;
}
    @RequestMapping(value = "/selectRepairOrder",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "工单搜索接口",notes = "支持搜索和高级搜索",httpMethod = "get", response = JsonResult.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
public JsonResult selectRepairOrder(@RequestBody @ApiParam(name = "pageRecv",value = "存储高级搜索页面的数据信息",required = true)PageRecv<RepairOrder> pageRecv){
        JsonResult r=new JsonResult();
        r=repairOrderService.selectRepairOrder(pageRecv);
        return r;
}
    @RequestMapping(value = "/selectRepairOrderByOther",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "工单普通搜索接口",notes = "支持普通搜索",httpMethod = "post", response = JsonResult.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
public JsonResult selectRepairOrderByOther(@RequestBody @ApiParam(name = "pageRecv",value = "存储普通搜索格的数据信息",required = true)PageRecv<RepairOrder> pageRecv){
        JsonResult jsonResult=new JsonResult();
        jsonResult=repairOrderService.selectRepairOrderByOther(pageRecv);
        return jsonResult;
}
@RequestMapping(value = "/updateRepairOrder",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "工单修改",notes = "支持修改处理状态、整体的修改",httpMethod = "post", response = JsonResult.class)
@ApiResponses({
        @ApiResponse(code=200,message="请求成功"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=500,message="后台服务错误")
})
public R updateRepairOrder(@RequestBody @ApiParam(name = "repairOrder",value = "工单数据实体",required = true) RepairOrder repairOrder){
        R r=new R();
    System.out.println(repairOrder.toString());
        r=repairOrderService.updateRepairOrder(repairOrder);
        return r;
}
@RequestMapping(value = "/deleteRepairOrder",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "工单删除",notes = "支持删除功能",httpMethod = "get", response = JsonResult.class)
@ApiImplicitParams({
        @ApiImplicitParam(name = "repair_id",value = "工单id",required = true,dataType = "String",paramType = "query"),
        @ApiImplicitParam(name = "delete_reason",value = "删除原因",required = true,dataType = "String",paramType = "query"),
})
@ApiResponses({
        @ApiResponse(code=200,message="请求成功"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=500,message="后台服务错误")
})
public R deleteRepairOrder(Integer repair_id,String delete_reason){
        R r=new R();
        r=repairOrderService.deleteRepairOrder(repair_id);
    return r;
}
//数据统计按员工Data statistics by employee
@RequestMapping(value = "/dataStatisticalByEmployee",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "数据统计",notes = "按员工",httpMethod = "get", response = JsonResult.class)
@ApiImplicitParams({
        @ApiImplicitParam(name = "start_date",value = "开始时间",required = true,dataType = "String",paramType = "query"),
        @ApiImplicitParam(name = "stop_date",value = "结束时间",required = true,dataType = "String",paramType = "query"),
})
@ApiResponses({
        @ApiResponse(code=200,message="请求成功"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=500,message="后台服务错误")
})
    public R dataStatisticalByEmployee(String start_date,String stop_date){
        R r=new R();
    System.out.println(start_date);
    System.out.println(stop_date);
        r=repairOrderService.dataStatisticalByEmployee(start_date,stop_date);
        return r;
    }
// 数据统计按部门Data statistics by department
@RequestMapping(value = "/dataStatisticalByDept",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "数据统计",notes = "按部门",httpMethod = "get", response = JsonResult.class)
@ApiImplicitParams({
        @ApiImplicitParam(name = "start_date",value = "开始时间",required = true,dataType = "String",paramType = "query"),
        @ApiImplicitParam(name = "stop_date",value = "结束时间",required = true,dataType = "String",paramType = "query"),
})
@ApiResponses({
        @ApiResponse(code=200,message="请求成功"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=500,message="后台服务错误")
})
    public R dataStatisticalByDept(String start_date,String stop_date){
        R r=new R();
        r=repairOrderService.dataStatisticalByDept(start_date,stop_date);
        return r;
    }
}
